package com.lqw.vhr.service;

import com.lqw.vhr.mapper.AdjustSalaryMapper;
import com.lqw.vhr.mapper.EmployeetrainMapper;
import com.lqw.vhr.model.AdjustSalary;
import com.lqw.vhr.model.Employeeremove;
import com.lqw.vhr.model.Employeetrain;
import com.lqw.vhr.model.RespPageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AdjustSalService {

    @Autowired
    AdjustSalaryMapper adjustSalaryMapper;

    public RespPageBean getAdjustSalByPage(Integer page, Integer size, String keyword) {
        if (page != null && size != null) {
            page = (page - 1) * size;
        }
        List<AdjustSalary> adjustSalaries = adjustSalaryMapper.getAdjustSalByPage(page, size, keyword);
        long total = adjustSalaryMapper.countAdjustSalByPage(page, size, keyword);
        RespPageBean respPageBean = new RespPageBean();
        respPageBean.setData(adjustSalaries);
        respPageBean.setTotal(total);
        return respPageBean;
    }

    public int updateAdjustSal(AdjustSalary adjustSalary) {
        return adjustSalaryMapper.updateByPrimaryKeySelective(adjustSalary);
    }

    public int addAdjustSal(AdjustSalary adjustSalary) {
        return adjustSalaryMapper.insertSelective(adjustSalary);
    }

    public int deleteAdjustById(Integer id) {
        return adjustSalaryMapper.deleteByPrimaryKey(id);
    }


}
